home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
os2
/
sockd.zip
/
sockdrep.cmd
< prev
Wrap
OS/2 REXX Batch file
|
1997-03-12
|
6KB
|
215 lines
/**************************************************************************/
/* */
/* sockdrep.cmd : A sample Rexx program to report sockd activities */
/* */
/* This program reads the archived sockdlog.XXX files in the current */
/* directory and writes the activity report to the screen. */
/* */
/* Usage : enter "sockdrep" without parameter */
/* */
/* Philippe Gillain March 1997*/
/**************************************************************************/
'@echo off'
trace off
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
parse upper arg Parm_field;
if Parm_field = '?' | Parm_field = 'HELP' then do
call usage
exit
end
numeric digits 15
numeric form engineering
numeric fuzz 0
host_nb = 0
dial_up_Nb = 0
dial_up_HH = 0
dial_up_MM = 0
dial_up_start_day = 0
dial_up_start_time = " "
dial_up_end_day = 0
dial_up_end_time = " "
dial_up_delay = 0
/*------------------------------------------------------------------
* read the parameters
*------------------------------------------------------------------*/
/* parse arg file_name line_name line_name2 . */
file_name = "sockdlog.001"
start_time = "-"
start_day = " "
start_month = " "
end_time = " "
end_day = " "
end_month = " "
cur_hour = 0
i = 0
j = 0
k = 0
call SysFileTree 'sockdlog.*', 'filename', 'F'
do i = 1 to filename.0
file_name = word(filename.i,5)
if lines(file_name) > 0 then do
work_line = linein(file_name)
if word(work_line,1) = "sockdlog" then do
if start_time = "-" then do
start_month = word(work_line,4)
start_day = word(work_line,5)
start_time = word(work_line,6)
end
do while lines(file_name) > 0
work_line = linein(file_name)
word1 = word(work_line,1)
SELECT
WHEN word1 = "dial-up" THEN call DialUp;
WHEN word1 = "session" THEN call Session;
WHEN word1 = "error" THEN call ErrorRep;
WHEN word1 = "sockdlog" THEN do;
end_month = word(work_line,4)
end_day = word(work_line,5)
end_time = word(work_line,6)
end;
OTHERWISE
END
end
end
end
end
say 'Report from ' || start_month || " " || start_day || " " || start_time || " to " ,
|| end_month || " " || end_day || " " || end_time
say ' '
say 'Number of dial-up sessions ' || dial_up_Nb
say 'Total dial-up connection time ' || RIGHT(dial_up_HH,5,' ') || ":" ,
|| RIGHT(dial_up_MM,2,'0') || " hours"
say ' '
say ' depress ENTER to continue '
Pull answer .
call SysCls
say ' '
say ' Destination Port Session Nb Bytes Sent Bytes Rcvd'
say ' '
j = 0
do i = 1 to host_nb
j = j + 1
say LEFT(name.i,30) || ' ' || RIGHT(port.i,5,' ') || ' ' ,
RIGHT(session_nb.i,6,' ') || ' ' || RIGHT(bytin.i,12,' ') ,
|| ' ' || RIGHT(bytout.i,12,' ')
if j > 16 then do
say ' '
say ' depress ENTER to continue '
j = 0
Pull answer .
call SysCls
say ' '
say ' Destination Port Session Nb Bytes Sent Bytes Rcvd'
say ' '
end
end
exit
DialUp:
if word(work_line,4) = "established" then do
dial_up_start_day = word(work_line,7)
dial_up_start_time = word(work_line,8)
dial_up_delay = 0
end
else
if word(work_line,4) = "closed" then do
dial_up_end_day = word(work_line,7)
dial_up_end_time = word(work_line,8)
if dial_up_end_day = dial_up_start_day then do
HH1 = SUBSTR(dial_up_start_time,1,2)
MM1 = SUBSTR(dial_up_start_time,4,2)
HH2 = SUBSTR(dial_up_end_time,1,2)
MM2 = SUBSTR(dial_up_end_time,4,2)
if MM2 < MM1 then do
MM2 = MM2 + 60
HH2 = HH2 -1
end
dial_up_Nb = dial_up_Nb + 1
dial_up_HH = dial_up_HH + HH2 - HH1
dial_up_MM = dial_up_MM + MM2 - MM1
if dial_up_MM > 59 then do
dial_up_HH = dial_up_HH + 1
dial_up_MM = dial_up_MM - 60
end
end
end
RETURN
Session:
host_name = word(work_line,11)
word1 = word(work_line,12)
j = LENGTH(word1)
if j > 7 then do
host_port = SUBSTR(word1,7,(j-7))
end
else host_port = 0
word2 = word(work_line,13)
k = LENGTH(word2)
if k > 4 then do
word3 = SUBSTR(word2,5,k)
l = pos('/',word3)
m = LENGTH(word3)
n = l - 1
word4 = SUBSTR(word3,1,n)
host_in = word4
n = m -l
l = l + 1
word4 = SUBSTR(word3,l,n)
host_out = word4
end
else do
host_in = 0
host_out = 0
end
not_found = 'Y'
do k = 1 to host_nb
if (name.k = host_name) & (port.k = host_port) then do
session_nb.k = session_nb.k + 1
bytin.k = bytin.k + strip(host_in)
bytout.k = bytout.k + strip(host_out)
not_found = 'N'
k = host_nb
end
end
if not_found = 'Y' then do
host_nb = host_nb + 1
name.host_nb = host_name
port.host_nb = host_port
session_nb.host_nb = 1
bytin.host_nb = strip(host_in)
bytout.host_nb = strip(host_out)
end
RETURN
ErrorRep:
if word(work_line,1) = "refused" then do
say work_line
end
RETURN
/*------------------------------------------------------------------
* some simple help
*------------------------------------------------------------------*/
Usage: procedure
say " "
say "usage : "
say " start sockrep in the directory containing the sockdlog files "
say " "
exit